#ifndef TASK_POOL_H
#define TASK_POOL_H

#include <condition_variable>
#include <memory>
#include <mutex>
#include <queue>

class AbstractTask;

class TaskPool
{
public:
    TaskPool(std::int32_t bufferSize = BUFSIZ);

    void append(std::shared_ptr<AbstractTask> task);
    std::shared_ptr<AbstractTask> takeFirst();

    bool empty() const;
private:
    const std::int32_t m_bufferSize;
    std::queue<std::shared_ptr<AbstractTask>> m_taskPool;
    std::shared_ptr<std::mutex> m_mutex;
    std::shared_ptr<std::condition_variable> m_condition;
};

#endif // TASK_POOL_H


